// pages/contact/contact.js
const app = getApp()
var QQMapWX = require('../../utils/qqmap-wx-jssdk.min.js');
var qqmapsdk = new QQMapWX({
  key: 'J3ZBZ-WWXKJ-57RFY-FR7UP-OMKPK-GMBSJ'
});
Page({

  /**
   * 页面的初始数据
   */
  data: {
    activeNames: ['1'],
    editstatus:true,
    show: false,
    imgurl:'',
    value: '13808867505',
    tel:'13808867505',
    email:'773798912@qq.com',
    address:'广州市海珠区张王直13号101房',
    starShow:true,
    introduce: '易拍居，法拍房顾问机构。运营“易拍居”公众号，提供“易拍居”（微信小程序）一站式全国法拍房信息检索及服务平台，在法拍房和二手房市场跨市场提供优化置业方案，为投资法拍房保驾护航，保障投资人竞拍不拍贵，不踩坑。房住不炒，买房先看易拍居。'
  },
  // account(e){
  //   console.log(e)
  // },
  positioning(e) {
    console.log(e)
    let that = this;
    qqmapsdk.geocoder({
      address:that.data.address,
      success: function (res) {
        const latitude = res.result.location.lat;
        const longitude = res.result.location.lng;
        wx.openLocation({
          latitude,
          longitude,
          name:that.data.address,
          scale: 18
        })
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },
  phoneCall(e){
    let phoneNumber = e.currentTarget.dataset.phone;
    console.log(e)
    wx.makePhoneCall({
      phoneNumber,
      fail(res){
        console.log(res)
      }
    })
  },
  star(e){
    this.setData({
      starShow:!this.data.starShow
    })
  },
  showclick(){
    let that =this;
    this.setData({ show : true })
    let json = { category : 'getwxacodeunlimit' } //有个数限制
    let inviId = 'fafaaaaaaaaaaaaaaaaaaaaaaaa' //房源签约id
    let type = 1 //订单类型  1优选、2折扣、3放盘
    let userid = 'gaaaaaaaaaaaaaaaaaa' //用户id、绑定当前用户
    let housetype = 1 //房源类型1优选、2折扣
    let data = {
      appid: getApp().globalData.appid, //小程序id
      path: "pages/order/order",//扫码进入那个页面
      params: JSON.stringify({id:inviId,type:type,userId:userid,housetype:housetype}) //房源id、房源类型、订单类型、用户id
    }
      getApp().ports.apiqrcode({data,json}).then((res)=>{
      // console.log(res)
      // let base64 = wx.arrayBufferToBase64(res.data)
      that.setData({ imgurl : 'data:image/png;base64,'+res.data})
    }).catch(()=>{console.error('生成二维码错误！')})
  },
  getUserInfo(event) {
    console.log(event.detail);
  },
  onClose() {
    this.setData({ close: false });
  },
  change(){
    // this.setData({ editstatus : false })
    wx.showToast({
      title: '暂未开放',
      icon: 'none',
      duration: 1500
    })
  },
  close(){this.setData({ editstatus : true })},
  //修改ee
  confirm(){
    this.setData({ editstatus : true })
    // console.log(this.data.address)
    // console.log(this.data.value)
  },
  // Changeaddress(event) {this.setData({ address : event.detail.value })},
  // Changevalue(event) {this.setData({ value : event.detail.value })},
  // Changetel(event) {this.setData({ tel : event.detail.value })},
  // Changeemail(event) {this.setData({ email : event.detail.value })},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.hideShareMenu({
      menus: ['shareAppMessage', 'shareTimeline']
    })
    this.setData({
      tel:app.globalData.phone,
      value:app.globalData.phone
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    let that = this;
    var sharehouseId = 'fgagagaggggggggg'; //房源id
    let type = 1 //订单类型  1优选、2折扣、3放盘
    let userid = 'gagaaaaaaaaaaaaaaaaaaa' //当前id/用于绑定
    let housetype = 1 //房源类型1优选、2折扣
    return {
      title: '去邀请更多小伙伴一起看房吧',
      path: '/pages/order/order?sharehouseId='+sharehouseId+'&type='+type+'&userid'+userid+'&housetype'+housetype,
      success: function(res) {}
    }
  }
})